{% extends "projects/base_project.html" %}
{% load i18n %}
{% load projects_tags %}
{% load privacy_tags %}
{% load core_tags %}

{% block title %}
Versions
{% endblock title %}

{% block project_editing %}
  {% with versions_active="active" %}
    {% include "core/project_bar.html" %}
  {% endwith %}
{% endblock %}


{% block content %}

  <div class="project-version-list">

    <div class="module project-versions-active">
      <div class="module-wrapper">

        <div class="module-header">
          <h1>{% trans "Active Versions" %}</h1>
        </div>

        <div class="module-list">
          <div class="module-list-wrapper">
            <ul>
              {% for version in active_versions|sort_version_aware %}
                {% block active-versions %}
                  <li class="module-item">
                    {# Link to the docs #}
                    <a class="module-item-title" href="{{ version.get_absolute_url }}">{{ version.slug }}</a>

                    {% if request.user|is_admin:project %}
                      <span class="right-menu">
                        {{ version.get_privacy_level_display }}
                      </span>
                    {% endif %}

                    {% if not version.slug in version.identifier %}
                      <span class="right-menu quiet version-branch">{{ version.identifier_friendly|truncatechars:24 }}</span>
                    {% endif %}

                    {% if request.user|is_admin:project %}
                      <ul class="module-item-menu">
                        <li><a href="{% url "project_version_detail" project.slug version.slug %}">{% trans "Edit" %}</a></li>
                      </ul>
                    {% else %}
                      <ul class="module-item-menu">
                        <li><a href="{{ version.get_absolute_url }}">{% trans "View Docs" %}</a></li>
                      </ul>
                    {% endif %}

                  </li>
                {% endblock active-versions %}

              {% empty %}
                <li class="module-item">
                  <p class="quiet">
                    {% trans "No active versions." %}
                  </p>
                </li>
              {% endfor %}
            </ul>
          </div>
        </div>

      </div>
    </div>

    {% if request.user|is_admin:project or request.user.is_staff %}
    <div class="module project-versions-inactive">
      <div class="module-wrapper">

        {% if inactive_versions %}
          <div class="module-header">
            <h1>{% trans "Inactive Versions" %}</h1>
          </div>

          <div class="module-list">
            <div class="module-list-wrapper">
              <ul>
                {% for version in inactive_versions|sort_version_aware %}

                  {% block inactive-versions %}
                    <li class="module-item">
                      {# Link to the docs #}
                      <span class="quiet">{{ version.slug }}</span>


                      {% if request.user|is_admin:project %}
                        <span class="right-menu">
                          {{ version.get_privacy_level_display }}
                        </span>
                      {% endif %}

                      {% if not version.slug in version.identifier_friendly %}
                        <span class="right-menu quiet version-branch">{{ version.identifier_friendly|truncatechars:24 }}</span>
                      {% endif %}

                      {% if request.user|is_admin:project %}
                        <ul class="module-item-menu">
                          <li><a href="{% url "project_version_detail" project.slug version.slug %}">{% trans "Edit" %}</a></li>
                        </ul>
                      {% endif %}

                    </li>
                  {% endblock inactive-versions %}

                {% endfor %}
              </ul>
            </div>
          </div>
        {% endif %}

      </div>
    </div>
    {% endif %}

  </div>
{% endblock %}
